package resp

import (
	"github.com/cloudwego/hertz/pkg/app"
	"net/http"
)

type Resp struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Data    any    `json:"data,omitempty"`
}

func BaseResponse(c *app.RequestContext, statusCode, code int, message string, data any) {
	c.JSON(statusCode, Resp{
		Code:    code,
		Message: message,
		Data:    data,
	})
}

func SuccessResponse(c *app.RequestContext, message string, data any) {
	BaseResponse(c, http.StatusOK, 0, message, data)
}

func BadRequestResponse(c *app.RequestContext, code int, message string) {
	BaseResponse(c, http.StatusBadRequest, code, message, nil)
}

func NotFountResponse(c *app.RequestContext, message string) {
	BaseResponse(c, http.StatusNotFound, 4, message, nil)
}
